package test;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.util.Observable;
import java.util.Observer;

/**
 * Created by Connor Madden.
 * User: Connor Madden
 * Date: 20/08/11
 * Time: 9:07 PM
 */
public class testGUI {


    public static void main(String[] args) {
        final Lift lift = new Lift(0);
        final JLabel label = new JLabel("");
        lift.addObserver(new Observer() {
            public void update(Observable o, Object arg) {
                label.setText(Integer.toString(((Lift) o).getLoc()));
//                if (arg == Lift.Change.LOC_CHANGE) System.out.println("Move: " + lift.getPrevLoc() + " To " + lift.getLoc());
//                else if (arg == Lift.Change.DOOR_OPEN) System.out.println("Open Door");
//                else if (arg == Lift.Change.DOOR_CLOSE) System.out.println("Close Door");
            }
        });
        final Dispatch dispatch = new Dispatch(lift);

        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JComboBox jComboBox = new JComboBox();
        jComboBox.addItem("1");
        jComboBox.addItem("2");
        jComboBox.addItem("3");
        jComboBox.addItem("4");
        jComboBox.addItem("5");
        jComboBox.addItem("6");
        jComboBox.addItem("7");
        jComboBox.addItem("8");
        jComboBox.addItem("9");
        jComboBox.addItem("10");
        jComboBox.addItemListener(new ItemListener() {
            public void itemStateChanged(ItemEvent e) {
                dispatch.addDisembark(Integer.parseInt(e.getItem().toString()));
            }
        });
        JPanel panel = new JPanel(new GridLayout(2, 1));
        panel.add(label);
        panel.add(jComboBox);
        frame.add(panel);
        frame.pack();
        frame.setVisible(true);
    }

//    private JComboBox comboBox1;
//    Lift lift;
//    Dispatch dispatch;
//
//    public LiftGUI() {
//        lift = new Lift(0);
//        lift.addObserver(new Observer() {
//            public void update(Observable o, Object arg) {
//                if (arg == Lift.Change.LOC_CHANGE) System.out.println("Move: " + lift.getPrevLoc() + " To " + lift.getLoc());
//                else if (arg == Lift.Change.DOOR_OPEN) System.out.println("Open Door");
//                else if (arg == Lift.Change.DOOR_CLOSE) System.out.println("Close Door");
//            }
//        });
//        dispatch = new Dispatch(lift);
//        comboBox1.addItemListener(new ItemListener() {
//            public void itemStateChanged(ItemEvent e) {
//                dispatch.addDisembark(Integer.parseInt(e.paramString()));
//            }
//        });
//    }
}
